package Panels;

import java.awt.BorderLayout;
import java.awt.Insets;
import java.io.BufferedReader;
import java.io.FileReader;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import Code.TablePanelInfo;


public class SQLQuery extends JPanel{

	private TablePanelInfo TPInfo;
	
	public SQLQuery(TablePanelInfo TPanelInfo){
		TPInfo=TPanelInfo;
		
		setLayout(new BorderLayout());
		JTextArea QueryEditPane=new JTextArea();
		TPInfo.SetTextArea(QueryEditPane);
		add(new QueryToolBar(TPInfo),BorderLayout.NORTH);
		QueryEditPane.setMargin(new Insets(5,5,5,5));
		try{
			String Line;
			FileReader Reader=new FileReader(TPInfo.GetQueryLocation());
	        BufferedReader BReader=new BufferedReader(Reader);
	        do{
	        	QueryEditPane.read(BReader,null);
	        }while((Line=BReader.readLine())!=null);
		}catch(Exception e){}
		JScrollPane ScrollPane=new JScrollPane(QueryEditPane);
		add(ScrollPane,BorderLayout.CENTER);
	}
}
